 //* Created by Administrator on 2019/5/19.
var year = prompt("请输入年份：");
var month = prompt("请输入月份：");
 year =Number(year);
 month =Number(month);
function runnian(year) {
    if(year%400==0||year%4==0&&year%100!=0){
        return true;
    }else{
        return false;
    }
}
var days = 0;
for(var i=1980;i<=2018;i++){
    if(runnian(i)){
        days +=366
    }
    else {
        days +=365;
    }
}
for(var k=1;k<month;k++){
    switch (k){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            days+=31;
            break;
        case 2:
            if(runnian(year)){
                days+=29;
            }else{
                days+=28;
            }
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            days+=30;
            break;
    }
}
days+=2;
var start =days % 7;
var day =document.querySelector("#day");
var pday =0;
switch (month-1){
    case 0:
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
        pday=31;
        break;
    case 2:
        if(runnian(year)){
            pday+=29;
        }else{
            pday+=28;
        }
        break;
    case 4:
    case 6:
    case 9:
    case 11:
        pday+=30;
        break;}
var thisday =0;
switch (month){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
        thisday+=31;
        break;
    case 2:
        if(runnian(year)){
            thisday+=29;
        }else{
            thisday+=28;
        }
        break;
    case 4:
    case 6:
    case 9:
    case 11:
        thisday+=30;
        break;}
for(var j =pday-start+1;j<=pday; j++) {
    day.innerHTML += '<span class="h">' + j + '</span>';}
var d = new Date().getDate();
for(var s =1 ;s<=thisday;s++){
    if(s===d){
        day.innerHTML+= '<span class="today">'+s+'</span>';
    }else {
        day.innerHTML+= '<span >'+s+'</span>';
    }
}
var num =42
var endday =num-start -thisday;
for(var e =1; e<=endday;e++){
    day.innerHTML+= '<span class="h">'+e+'</span>';}
document.querySelector("#nian").innerHTML =year;
document.querySelector("#yue").innerHTML =month;